import{b3 as s}from"./DrFvzlh8agutd.js";import{e as u}from"./MpnPZlTSagutd.js";function c(t){return t.replace(/^(https?:\/\/(www\.)?|mailto:)/gi,"").replace(/\/$/,"")}u(c,"toHumanReadableUrl");var h=/((?:(?:https?|ftp):)?\/\/(?:\S+@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[01])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4])|(?:(?:[a-z0-9\u00A1-\uFFFF][\w\u00A1-\uFFFF-]{0,62})?[a-z0-9\u00A1-\uFFFF]\.)+[a-z\u00A1-\uFFFF]{2,}\.?)(?::\d{2,5})?(?:[/?#]\S*)?)/gi;function A(t){return t.split(h).map((e,r)=>{let n=s(e);return r%2?`<a target="_blank" rel="noopener noreferrer" href="${n}">${c(n)}</a>`:n}).join("")}u(A,"linkifyPlainTextSimple");var b=/((mailto:)?[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})/gi,y=/([a-zA-Z0-9]+\.[a-zA-Z]{2,})/gi;function g(t){var e=t,r=[];let n=e.replace(/[.,!?;:]*$/,"");if(r.unshift(e.slice(n.length)),e.includes("://")){e=n;let a=(e.match(/[\(\[\{]/g)||[]).length,f=(e.match(/[\)\]\}]/g)||[]).length;if(f>a){let $=f-a,F=new RegExp(`[\\)\\]\\}]{0,${$}}$`,"g"),d=e.replace(F,"");r.unshift(e.slice(d.length)),e=d}}else e.includes("@")?e.startsWith("mailto:")||(e=`mailto:${n}`):e=`https://${n}`;let i=s(r.join("")),l=s(c(e)),o=s(e);return`<a target="_blank" rel="noopener noreferrer"${e.startsWith("http://")?' class="_warn"':""} href="${o}">${l}</a>${i}`}u(g,"handleUrlString");var p=void 0;function m(t,e={}){p==null?p=new RegExp(`((${h.source})|(${b.source})|(${y.source}))`,"gi"):p.lastIndex=0;var r=0;let n=[];return t.replace(p,(i,...l)=>{let o=l[l.length-2],a=t.slice(r,o)??"";return n.push(s(a)),r=o+i.length,n.push(g(i)),i}),n.join("")+s(t.slice(r))}u(m,"linkifyPlainText");function x(t,e={}){return t.split(`
`).map(r=>m(r,e)).join("<br>")}u(x,"linkifyPlainTextWithLineBreaks");function z(t,e){let r=[];for(let[n,i]of Object.entries(t))if(i!=null){Array.isArray(i)||(i=[i]);for(let l of i)e&&!e(l)||l!=null&&r.push(`${encodeURIComponent(n)}=${encodeURIComponent(String(l))}`)}return r.join("&")}u(z,"encodeQuery");function R(t){let e={};for(;t.startsWith("?");)t=t.substring(1);let r=t.split("&");for(let n=0;n<r.length;n++){let i=r[n],l=i.indexOf("=");if(i.length===0)continue;let o=l<0?i:decodeURIComponent(i.substring(0,l)),a=l<0?"":decodeURIComponent(i.substring(l+1));e[o]!=null?(Array.isArray(e[o])||(e[o]=[e[o]]),e[o].push(a)):e[o]=a}return e}u(R,"parseQuery");export{z as U,c as g};